﻿namespace ManagerClinic.KhamBenh
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using DevExpress.XtraEditors;
    using ManagerClinic.Core.Business;
    using ManagerClinic.Core.Common;
    using ManagerClinic.Modules;
    using System.Linq;

    public partial class frmDanhSachBenhNhanKhamBenh : DevExpress.XtraEditors.XtraForm
    {
        PhieuKhamBenhBusiness phieuKhamBenhBusiness = null;
        IList<PhieuKhamBenhEntity> lstDanhSachKhamBenh = null;

        public frmDanhSachBenhNhanKhamBenh()
        {
            InitializeComponent();
            phieuKhamBenhBusiness = new PhieuKhamBenhBusiness();
        }

        public void LoadDanhSachKhamBenh() {
            lstDanhSachKhamBenh = phieuKhamBenhBusiness.GetPhieuKhamBenhList(Convert.ToDateTime(dtCurrentDate.EditValue),(int)radTrangThaiKhamBenh.EditValue);
            if (lstDanhSachKhamBenh.Count > 0)
            {
                if (lstDanhSachKhamBenh.Count > 0) {
                    lstDanhSachKhamBenh = lstDanhSachKhamBenh.Where(n => Authenticate.ChuoiPhongKhamVaCanLamSangString.Contains(n.MaPhongKham)).ToList();
                }
            }
            grdDanhSachBenhNhanKhamBenh.DataSource = lstDanhSachKhamBenh;
        }

        private void frmDanhSachBenhNhanKhamBenh_Load(object sender, EventArgs e)
        {
            dtCurrentDate.EditValue = DateTime.Now;
        }

        private void radTrangThaiKhamBenh_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoadDanhSachKhamBenh();
        }
    }
}